/**
 * 这个文件模块中专门进行路由表配置
 */
import NavBar from '../components/nav-bar/index.vue'
import TabBar from '../components/tab-bar/index.vue'

//路由懒加载
const Home = () => import('../views/home/index.vue')
const Login = () => import('../views/login/index.vue')
const Register = () => import('../views/register/index.vue')
const Cart = () => import('../views/cart/index.vue')
const CateGory = () => import('../views/category/index.vue')
const Mine = () => import('../views/mine/index.vue')
const Detail = () => import('../views/detail/index.vue')
const Search = () => import('../views/search/index.vue')
const NotFound = () => import('../views/not-found/index.vue')
const Order = () => import('../views/order/index.vue')
const Address = () => import('../views/address/index.vue')


// 路由表数组配置
const routes = [
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/home',
        components:{
            default: Home,
            footer: TabBar
        },
        meta: { 
            showTabBar: true,   //标记当前路由需要作为 tabbar 中的 tab项渲染
        }
    },
    {
        path: '/login',
        components:{
            header: NavBar,
            default: Login,
        },
        meta: { title: '登录' }
    },
    {
        path: '/register',
        components:{
            header:NavBar,
            default: Register
        },
        meta: { title: '注册'}
    },
    {
        path: '/search',
        components:{
            header: NavBar,
            default: Search,
        },
        meta: { title: '搜索' }
    },
    {
        path: '/detail',
        components:{
            header: NavBar,
            default: Detail,
        },
        meta: { 
            title: '商品详情' ,
            needLogin: true,
        }
    },
    {
        path: '/mine',
        components:{
            header: NavBar,
            default: Mine,
            footer: TabBar,
        },
        meta: { 
            title: '我的' ,
            showTabBar:true,
            needLogin: true,
        }
    },
    {
        path: '/cart',
        components:{
            header: NavBar,
            default: Cart,
            footer: TabBar,
        },
        meta:{ 
            title: '购物车' ,
            showTabBar: true,
            needLogin: true,
        }
    },
    {
        path: '/category',   //分类的路由
        components:{
            header: NavBar,
            default: CateGory,
            footer: TabBar,
        },
        meta:{ 
            title: '分类',
            showTabBar: true,
        }
    },
    {
        path: '/order',
        components: {
            header: NavBar,
            default: Order,
        },
        meta: {
            title: '我的订单',
            needLogin: true,
        }
    },
    {
        path: '/address',
        components: {
            header: NavBar,
            default: Address,
        },
        meta: {
            title: '我的地址',
            needLogin: true,

        }
    },
    {
        path: '/:pathMatch(.*)*',
        component: NotFound,
    }
]

//导出
export default routes